<extend name="Public/layout"/>
<block name="head">
    <link rel="stylesheet" href="__PUBLIC__css/change-password.css">
<style type="text/css">
.footer{
    display: none;
}
</style>
 </block>
 <block name="main">
    <div class="form">
        <div class="form-group">
            <input type="password" id="old_password" placeholder="请输入原密码">
        </div>
<!--         <div class="drop-msg">
            <p>您输入的密码有误，请重新输入</p>
        </div> -->
        <div class="form-group">
            <input type="password" id="new_password" placeholder="请设置新密码">
        </div>
        <div class="form-group">
            <input type="password" id="new_password2" placeholder="请确认新密码">
        </div>
    </div>
    <div class="btn-wrapper">
        <a href="javascript:" onclick="sub()">保存</a>
    </div>
 <block name="js">
    <script type="text/javascript">
    function sub(){
        var old_password = $('#old_password').val();
        var new_password = $('#new_password').val();
        var new_password2 = $('#new_password2').val();

         if(!new_password || !new_password2 || !old_password){
             layer.open({
                    content:"请填写完整"
                    ,skin: 'msg'
                    ,time: 1
                });
             return;
        }

        if(new_password!=new_password2){
             layer.open({
                    content:"两次密码输入不一致"
                    ,skin: 'msg'
                    ,time: 1
                });
             return;
        }
       
        var old_password =  $.md5(old_password);
        var new_password =  $.md5(new_password);

        $.post('{:U("Person/change_password")}',{
            new_password:new_password,
            old_password:old_password,
        },function(res){
            console.log(res)
            if(res.err==0){
                layer.open({
                    content:res.msg
                    ,skin: 'msg'
                    ,time: 1
                    ,end:function(){
                        location.href="/Home/Person/setting";
                    }
                });
            }else{
                layer.open({
                    content:res.msg
                    ,skin: 'msg'
                    ,time: 1
                });

            }
        })
    }
    </script>
</block>